﻿using System;
using System.Collections.Generic;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using GamePlusClassLibrary;

namespace GamePlus.UserControls
{
    public partial class mod_mostplayed : System.Web.UI.UserControl
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
                this.loadContent();
        }

        private void loadContent()
        {
            //content.InnerHtml = string.Empty;
            //string sLi = string.Empty;
            //int cont = 0;
            //List<rating_most_played> ls = ratings.getMostPlayedToday();
            //ls.ForEach(delegate(rating_most_played obj) {

            //    sLi += "<li class=\""+ (cont.Equals(0) ? "active" : string.Empty) +" clr3\"><a href=\"/game/"+ obj.game_id.ToString() +"\">";
            //    sLi += "<img class=\"img bdc2\" src=\""+ getImgUrl(obj.game_id) +"\" alt=\"Nome do Jogo\" />";
            //    sLi += "<span class=\"game clr5\">"+ obj.game_name +"</span><br />";
            //    sLi += "<span class=\"smalltext\">Jogado: "+ obj.plays_count.ToString() +" vezes<br />High Score: "+ obj.score.ToString() +"</span></a></li>";

            //    cont++;

            //});

            //content.InnerHtml = sLi;
        }

        private string getImgUrl(int id)
        {
            string sZero = string.Empty;
            int cont = 3 - id.ToString().Length;
            for (int i = 0; i < cont; i++)
                sZero += "0";

            return "http://www.otzee.com.br/images/games/000/000/" + sZero + id.ToString() + "/spotlight_normal.jpg";
        }

        private string getDescription(string text, int length)
        {
            if (text.Length > length)
                text = text.Substring(0, length);
            return text;
        }

    }
}